<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>登录页面</title>
    <script src="/js/axios.js"></script>
  </head>
  <body>
    用户名<input type="text" /><span></span><br />
    密码<input type="password" /><br />
    <input type="button" value="登录" />
    <!-- 
        baseUrl:"http://localhost:3000"
        接口文档
        2.登录接口
        url:/users/login
        method:post
        params:username password 
        resData: {code:1,msg:"登录成功"} {code:0,msg:"用户名或密码错误，请重新登录"}
     -->
    <script>
      let aInputs = document.querySelectorAll("input");
      aInputs[2].addEventListener("click", loginHandle);
      function loginHandle() {
        let data = {
          username: aInputs[0].value,
          password: aInputs[1].value,
        };

        axios
          .post("http://localhost:3000/users/login", data)
          .then((resData) => {
            console.log(resData);
          });
      }
    </script>
  </body>
</html>
